package day03;

public class OperDemo {
    public static void main(String[] args) {
        //若为true，则整个表达式为？后的数字1
        //若为false，则整个表达式为：后的数字2
        int num = 0;
        int flag = num>0?1:-1;
        System.out.println(flag);

        int A = 10,B = 20;
        int max = A>B?A:B;
        System.out.println(max);

            //+字符
            //若两边都是数字，做加法
            //若两边出现了字符串"",做字符串连接
            //任何类型的数据与字符串相连，做字符串连接
        System.out.println(5+5+5+""+10+10);//151010
        System.out.println(""+5+5+5+10+10);//5551010
        System.out.println(5+5+5+10+10+"");//45
        int age = 24;
        System.out.println("age=");
        System.out.println(age);
        System.out.println("age="+age);
        System.out.println("我今年"+age+"岁了");

        String name = "TZL";
        System.out.println("大家好，我叫"+name);
        System.out.println("大家好，我叫"+name+"，我今年"+age+"岁了");


        short s = 5;
        s += 10;//相当于s=(short)(s+10)
                //强制类型转换

        int a = 5;
        a += 10;
        System.out.println(a);//15
        a *= 2;
        System.out.println(a);//30
        a /= 6;
        System.out.println(a);//5

        /*
                //&&并且，同时满足
        int a = 5,b = 10,c = 5;
        boolean b1 = b>=a && b<c;
        System.out.println(b1);//false
        System.out.println(b<=c && b>a);//false&&true
        System.out.println(a==b && b<a);//false&&false
        System.out.println(b!=c && b>a);//true&&true

        int age = 24;
        System.out.println(age>=18 && age<=30);//true
        int score = 90;
        System.out.println(score>=90 && score<=120);//true
                //||或者，满足其一
        System.out.println(b>a || c>b);//true
        System.out.println(score<0 || score>100);//false

                // ！ 非，非真就假，非假就真
        boolean b2 =!(a<b);
        System.out.println(b2);    //!true=false
        System.out.println(!(a>b));//!false=true

        /*
        int a = 10 ,b = 20,c =10;
        boolean a1 = a>b;
        System.out.println(a1);//false
        System.out.println(a>=c);//true
        System.out.println(b>c);//true
        System.out.println(a<=b);//true
        System.out.println(a==c);//true
        System.out.println(a!=c);//false
        System.out.println(a+c>b);//false
        System.out.println(++a>10);//true,++a为11，同时a自增1，变为11
        System.out.println(a++>10);//true，a自增1，变为12
        */

        /*
        单独使用时，在前在后都一样
        被使用时，++，--在前在后算法不同
        a++的值为a、a--的值为a
        ++a的值为a+1、--a的值为a-1


        int a = 5; int b =5;
        int c = a++;//将a++的值5赋值给c，同时a自增1
                    //a++的值为5，所以c为5
        int d = ++b;//将b++的值6赋值给d，同时d自增1
                    //++b的值为6，所以d为6
        System.out.println(a);//6
        System.out.println(b);//6
        System.out.println(c);//5
        System.out.println(d);//6
        */
    }
}
